import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class RelMain {
    public static void main(String[] args) {
        UserFactory userFactory = new UserFactory();
        UserInvoker invoker = new UserInvoker();
        List<Musician> musicians = new ArrayList<>();
        Musician musician0 = new Musician();
        Musician musician1 = new Musician();
        Musician musician2 = new Musician();
        Musician musician3 = new Musician();
        Musician musician4 = new Musician();
        musicians.addAll(Arrays.asList(musician0,musician1,musician2,musician3,musician4));
        List<Listener> listeners = new ArrayList<>();
        Listener listener0 = new Listener();
        Listener listener1 = new Listener();
        Listener listener2 = new Listener();
        Listener listener3 = new Listener();
        Listener listener4 = new Listener();
        listeners.addAll(Arrays.asList(listener0,listener1,listener2,listener3,listener4));
        Scanner scanner = new Scanner(System.in);
        while(true){
            System.out.println("请输入你需要的操作：1.创建新用户  2.执行命令 3.查看所有的用户");
            String s = scanner.nextLine();
            if(s.equals("1")){
                System.out.println("请选择你要创建的用户的身份： 1.Listener  2.Musician");
                String number = scanner.nextLine();
                if(number.equals("1")){
                    UserOfRela user = userFactory.createUser("Listener");
                    user.introduce();
                    listeners.add((Listener) user);
                }else {
                    UserOfRela user = userFactory.createUser("Musician");
                    user.introduce();
                    musicians.add((Musician) user);
                }
            }else if(s.equals("3")){
                musicians.forEach(System.out::println);
                listeners.forEach(System.out::println);
            }else {
                System.out.println("创建排序实例成功");
                Classify sort1 = new Sort1();
                Classify sort2 = new Sort2();

                UserCommand task1 = new Task1(sort1);
                UserCommand task2 = new Task2(sort2);
                System.out.println("创建命令对象成功");

                invoker.addOrder(task1);
                invoker.addOrder(task2);
                System.out.println("将命令添加到订单列表");

                invoker.notifyDo();
                System.out.println("开始执行命令");

                invoker.delOrder(task1);  // 假设我们想要取消第一个任务
                System.out.println("取消执行第一条命令");
                invoker.notifyNotDo();
            }
            String next = scanner.nextLine();
        }

    }
}
